<?php
/**
 * Created By PhpStorm
 * Author: patrick wu
 * Date: 2020/9/26
 * Time: 15:03
 */
namespace App\Http\Controllers\Admin;

use App\Http\Model\MongoDB\BasicModules;
use App\Http\Model\MongoDB\ShopTemplate;
use Carbon\Carbon;

class BasicController extends BaseController
{
    /**
     * 模板基础设置
     */
    public function settingBasic()
    {
        $basic_insert['basic_setting']  =   [
            [
                'name'  =>  'main_title',
                'desc'  =>  '模块主标题',
                'type'  =>  'input',
                'rules' =>  [
                    'min_length'    =>  1,
                    'max_length'    =>  100,
                ]
            ],
            [
                'name'  =>  'sub_title',
                'desc'  =>  '模块副标题',
                'type'  =>  'input',
                'rules' =>  [
                    'min_length'    =>  1,
                    'max_length'    =>  100,
                ]
            ],
            [
                'name'  =>  'is_show_bottom_margin',
                'desc'  =>  '是否显示下边距',
                'type'  =>  'select',
                'rules' =>  [
                    'options'   =>  [
                        [
                            'name'  =>  '显示',
                            'value' =>  1
                        ],
                        [
                            'name'  =>  '不显示',
                            'value' =>  0
                        ]
                    ]
                ]
            ]
        ];

        $basic_insert['advance_setting']=   [
            BasicModules::ANCHOR_PICTURE    =>  [
                [
                    'name'  =>  'picture_url',
                    'desc'  =>  '图片地址',
                    'type'  =>  'input',
                    'rules' =>  [
                        'file'  =>  [
                            'type'  =>  'image',
                            'extension' =>  ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
                            'file_size' =>  1024 * 1024 * 5,
                        ]
                    ]
                ]
            ],

            BasicModules::SWIPE_PICTURE     =>  [
                [
                    'name'  =>  'picture_url',
                    'desc'  =>  '图片地址',
                    'type'  =>  'input',
                    'rules' =>  [
                        'file'  =>  [
                            'type'  =>  'image',
                            'extension' =>  ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
                            'file_size' =>  1024 * 1024 * 5,
                        ]
                    ]
                ]
            ],

            BasicModules::SLIDER_PICTURE    =>  [
                [
                    'name'  =>  'picture_url',
                    'desc'  =>  '图片地址',
                    'type'  =>  'input',
                    'rules' =>  [
                        'file'  =>  [
                            'type'  =>  'image',
                            'extension' =>  ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
                            'file_size' =>  1024 * 1024 * 5,
                        ]
                    ]
                ]
            ],

            BasicModules::DOUBLE_PICTURE    =>  [
                [
                    'name'  =>  'is_show_plus_button',
                    'desc'  =>  '是否显示加购按钮',
                    'type'  =>  'select',
                    'rules' =>  [
                        'options'   =>  [
                            [
                                'name'  =>  '显示',
                                'value' =>  1
                            ],
                            [
                                'name'  =>  '不显示',
                                'value' =>  0
                            ]
                        ]
                    ]
                ],
                [
                    'name'  =>  'is_show_member_price',
                    'desc'  =>  '是否显示会员价',
                    'type'  =>  'select',
                    'rules' =>  [
                        'options'   =>  [
                            [
                                'name'  =>  '显示',
                                'value' =>  1
                            ],
                            [
                                'name'  =>  '不显示',
                                'value' =>  0
                            ]
                        ]
                    ]
                ],
                [
                    'name'  =>  'is_show_sale',
                    'desc'  =>  '是否显示销量',
                    'type'  =>  'select',
                    'rules' =>  [
                        'options'   =>  [
                            [
                                'name'  =>  '显示',
                                'value' =>  1
                            ],
                            [
                                'name'  =>  '不显示',
                                'value' =>  0
                            ]
                        ]
                    ]
                ],
                [
                    'name'  =>  'is_show_bottom_promoter',
                    'desc'  =>  '是否底部推广',
                    'type'  =>  'select',
                    'rules' =>  [
                        'options'   =>  [
                            [
                                'name'  =>  '显示',
                                'value' =>  1
                            ],
                            [
                                'name'  =>  '不显示',
                                'value' =>  0
                            ]
                        ]
                    ]
                ],
                [
                    'name'  =>  'choose_goods',
                    'desc'  =>  '选择商品',
                    'type'  =>  'input',
                    'rules' =>  [
                        'file'  =>  [
                            'type'  =>  'image',
                            'extension' =>  ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
                            'file_size' =>  1024 * 1024 * 5,
                        ]
                    ]
                ]
            ],

            BasicModules::NO_BORDER_PICTURE => [
                [
                    'name'  =>  'choose_goods',
                    'desc'  =>  '选择商品',
                    'type'  =>  'input',
                    'rules' =>  [
                        'file'  =>  [
                            'type'  =>  'image',
                            'extension' =>  ['jpg', 'jpeg', 'png', 'bmp', 'gif'],
                            'file_size' =>  1024 * 1024 * 5,
                        ]
                    ]
                ]
            ]
        ];

        $basic_insert['setting_id']     =   createUniqueID();

        $basic_insert['setting_time']   =   Carbon::now()->timestamp;

        $basic_result   =   BasicModules::create($basic_insert);
        dd($basic_result);
    }

    /**
     * 模板基础获取
     */
    public function gettingBasic()
    {
        $basic_result   =   BasicModules::query()->first();
        dd($basic_result);
    }
}
